/**
 * Created by ceshi-room on 2017/12/8.
 */
import ajax from './ajax';
import API from './apiuri';
const imgApi = API.imgApi;

export default {
  uploadImg (data) {
    return new Promise((resolve, reject) => {
      $.ajax({
        url: '/api/img/upload' ,  /*这是处理文件上传的servlet*/
        type: 'POST',
        data: data,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {
          let res = data;
          console.log(data)
          if (res.resultCode === 200 || res.resultCode === 0) {
            if (!res) {
              res = {resultData: 'success'};
            }
            resolve(res.resultData);
          } else {
            reject(res.resultMessage || 'failed');
          }
        },
        error: function (returndata) {
          reject(err);
        }
      });
    });
  }
}
